import ResUtil from "@/utils/resUtil";
import AxiosManager from "../axiosManager";
import type { Case } from "@/types/response/case";
import MediatorRank from "@/types/response/mediatorRank";
import type PaymentHistory from "@/types/response/paymentHistory";
import MediatorCase from "../../types/response/mediatorCase";
import OrgRank from "@/types/response/orgRank";
let instance = AxiosManager.caseAxios;
//获得调解机构的排行
async function getOrgsRank(){//从大到小排序
    let res=await instance.get("/case/orgRank",)
    return ResUtil.getData<OrgRank[]>(res);
}
//获得调解员近期的案件
async function getRecentCase(mId:number,day:number){
    let res=await instance.get("/recentCase/mediator",{
        params:{
            mId,
            day
        }
    })
    return ResUtil.getData<Case[]>(res);
}
//获得调解员指定日期的案件
async function getMediatorCaseByDay(mId:number,date:string){
    let res=await instance.get("/case/mediator/day",{
        params:{
            mId,
           date
        }
    })
    return ResUtil.getData<Case[]>(res);
}
//获得调解员所在年月的案件
async function getMediatorCaseByMonthYear(mId:number,year:number,month:number){
    let res=await instance.get("/case/mediator/monthYear",{
        params:{
            mId,
            year,
            month
        }
    })
    return ResUtil.getData<Case[]>(res);
}

//获得调解员所在组织的排行榜
async function getRankingList(mId:number){
   let res=await instance.get("/rankingList/mediatorOrg",{
     params:{
        mId
     }
   })
   return ResUtil.getData<MediatorRank[]>(res);
}
//获得调解员要调解的案件
async function getToDoCase(mId:number){
    let res=await instance.get("/todoCase/mediator",{
        params:{
            mId
        }
    });
    return ResUtil.getData<Case[]>(res);
}
//获得调解员的数据统计
async function getMediatorData(mId:number){
    let res=await instance.get("/case/mediatorData",{
        params:{
            mId
        }
    });
    return ResUtil.getData<MediatorCase>(res);
}
//获得待调解员处理的还款记录
async function getPaymentHistoryToDo(mId:number){
    let res=await instance.get("/paymentHistory/todo",{
        params:{
            mId
        }
    })
    return ResUtil.getData<PaymentHistory[]>(res);
}
export{
    getOrgsRank,
    getMediatorCaseByDay,
    getMediatorCaseByMonthYear,
    getRankingList,
    getRecentCase,
    getToDoCase,
    getMediatorData,
    getPaymentHistoryToDo
}